<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateGradeTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('grade', function (Blueprint $table) {
            $table->increments('id');
            $table->String('name',64)->default('')->comment('名称');
            $table->date('entrance_date')->comment('入学时间');
            $table->date('graduate_date')->comment('毕业时间');
            $table->integer('clbum_cnt')->default(0)->comment('班的数量');
            $table->bigInteger('leader_user_id')->default(0)->comment('年级组长');
            $table->String('desc',512)->default('')->comment('年级介绍');
            $table->string('created_user',64)->default('')->comment('创建人');
            $table->string('updated_user',64)->default('')->comment('修改人');
            $table->timestamps();
        });

        Schema::create('clbum', function (Blueprint $table) {
            $table->increments('id');
            $table->String('name',64)->default('')->comment('名称');
            $table->bigInteger('grade_id')->default(0)->comment('年纪ID');
            $table->bigInteger('header_teacher_user_id')->default(0)->comment('班主任用户ID');
            $table->String('desc',512)->default('')->comment('班级介绍');
            $table->string('created_user',64)->default('')->comment('创建人');
            $table->string('updated_user',64)->default('')->comment('修改人');
            $table->timestamps();
        });

        /**
         * 班级的扩展属性
         */
        Schema::create('clbum_ext', function (Blueprint $table) {
            $table->increments('id');
            $table->bigInteger('clbum_id')->comment('班级ID');
            $table->String('system_code_type',64)->default('')->comment('扩展类型');
            $table->String('system_code_value',64)->default('')->comment('扩展类型值');
            $table->String('value',64)->default('')->comment('扩展属性值');
            $table->string('created_user',64)->default('')->comment('创建人');
            $table->string('updated_user',64)->default('')->comment('修改人');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('grade');
        Schema::drop('clbum');
        Schema::drop('clbum_ext');
    }
}
